﻿using System.Collections.Generic;

namespace SessionByActionFilter.DAL
{

    public static class DataAccessLayerOpensTransaction
    {

        public static IEnumerable<Eg.Core.Book> GetBooks()
        {
            var session = MvcApplication.SessionFactory.GetCurrentSession();
            using (var tx = session.BeginTransaction()) {
                var books = session.QueryOver<Eg.Core.Book>()
                    .List();
                tx.Commit();
                return books;
            }
        }
    }
}